

using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using JYJ.AiYard.Authorization;

namespace JYJ.AiYard.StationManagement.TbDiscountBills.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="TbDiscountBillPermissions" /> for all permission names. TbDiscountBill
    ///</summary>
    public class TbDiscountBillAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public TbDiscountBillAuthorizationProvider()
		{

		}

        public TbDiscountBillAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public TbDiscountBillAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了TbDiscountBill 的权限。
			var pages = context.GetPermissionOrNull(AppLtmPermissions.Pages) ?? context.CreatePermission(AppLtmPermissions.Pages, L("Pages"));

			var administration = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_BasicDataManage) ?? pages.CreateChildPermission(AppPermissions.Pages_BasicDataManage, L("BasicDataManage"));

			var entityPermission = administration.CreateChildPermission(TbDiscountBillPermissions.Node , L("TbDiscountBill"));
			entityPermission.CreateChildPermission(TbDiscountBillPermissions.Query, L("QueryTbDiscountBill"));
			entityPermission.CreateChildPermission(TbDiscountBillPermissions.Create, L("CreateTbDiscountBill"));
            //entityPermission.CreateChildPermission(TbDiscountBillPermissions.Delete, L("DeleteTbDiscountBill"));
            //entityPermission.CreateChildPermission(TbDiscountBillPermissions.Edit, L("EditTbDiscountBill"));
            entityPermission.CreateChildPermission(TbDiscountBillPermissions.BatchDelete, L("BatchDeleteTbDiscountBill"));
            //entityPermission.CreateChildPermission(TbDiscountBillPermissions.ExportExcel, L("ExportExcelTbDiscountBill"));


        }

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AppConsts.LocalizationSourceName);
		}
    }
}